<template>
  <div>
    <headerXX :name="title"></headerXX>
    <div class="pull-refresh">
      <tabul :tabs="2" :list="list" :PDtab="PDtab" @tabFH="XXtab"></tabul>
      <div class="padding10 WZ_size_14" style="color: rgb(139, 147, 166)">
        选择服务项目
      </div>
      <!-- 子级tab（职工驿站车辆服务内容） -->
      <div v-if="tabwz == '职工驿站车辆服务内容'">
        <tabul
          :tabs="3"
          :list="listYZfu"
          :PDtab="PDtabYZFW"
          @tabFH="XXtabZJ"
        ></tabul>
        <div class="FWxx">
          <div
            class="ul"
            v-for="(item, index) in listYZfu"
            :key="index"
            v-if="item.goodId == PDtabYZFW"
          >
            <div class="li">
              <div class="li_left">
                <!-- <u--image
                width="150rpx"
                height="150rpx"
                :src="item.goodImage"
                mode=""
              ></u--image> -->
              </div>
              <div class="li_right">
                <div style="font-weight: 600">
                  {{ item.goodName }}
                </div>
                <div
                  class=""
                  style="font-size: 24rpx; color: rgb(2, 117, 113)"
                  v-if="item.goodPrice != 0"
                >
                  {{ item.goodPrice }}.00/小时
                </div>
              </div>
            </div>
            <div class="title">服务介绍：</div>
            <div class="text">
              {{ item.serviceDescription }}
            </div>
            <div class="FWGS" style="padding-top: 20rpx">
              <div class="l">服务单位名称：英大财险</div>
              <div class="l">服务人员名称：{{ item.serviceStaff }}</div>
              <div class="l">联系电话：{{ item.mobile }}</div>
            </div>
          </div>
        </div>
      </div>
      <!-- 子级（投保英大保险专享服务） -->
      <div class="" v-else>
        <div class="YBlist">
          <div
            class="ul"
            v-for="(item, index) in listYZfu"
            :key="index"
            @click="tabZX(item)"
          >
            <div
              class="li WZ_size_12"
              :class="item.id == PDtabYZFW ? 'cssXX' : ''"
            >
              {{ item.serviceName }}
            </div>
          </div>
        </div>
        <div class="NR">
          <div class="title">
            <div class="H">-</div>
            <div class="XX">服务介绍</div>
            <div class="H">-</div>
          </div>
          <div class="RYXX">
            <div class="text paddingTOP10">
              <div class="FWGS">
                <div class="l">服务单位名称：英大财险</div>
                <div class="l">服务人员名称：{{ serviceStaff }}</div>
                <div class="l">联系电话：{{ mobile }}</div>
                <div class="l">
                  详情介绍：
                  <span
                    v-if="
                      serviceDescription != undefined &&
                      serviceDescription != null
                    "
                  >
                    {{ serviceDescription }}</span
                  >
                  <span v-else>暂无详情介绍</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { testUserMessage } from "../../common/testUser.js";
import tabul from "../../components/tab.vue";
import { Toast } from "vant";
import headerXX from "../../components/title.vue";
import {
  getSiteCategoryList,
  getVehicleFinanceServiceList,
} from "@/api/realAssets/icsharedstation/getParent/index.js";
export default {
  components: { headerXX, tabul },
  data() {
    return {
      PDtabYZFW: 0,
      listYZfu: [],
      ZJG: 0,
      ZJname: "",
      serviceStaff: "",
      serviceDescription: "",
      mobile: "",
      PDtab: 0,
      tabwz: "",
      title: "金融服务",
      siteData: JSON.parse(localStorage.getItem("siteData")),
      list: [
        {
          goodId: 0,
          goodName: "健康自测一体机",
        },
        {
          goodId: 1,
          goodName: "人体成分分析仪",
        },
      ],
    };
  },
  created() {},
  mounted() {
    testUserMessage("金融服务").then((siteData) => {
      this.siteData = siteData[0];
      //获取服务列表
      getSiteCategoryList({
        siteId: this.siteData.id,
      }).then((res) => {
        if (res.resultCode == "1") {
          //拿到父级tab
          this.list = res.data.map((item) => {
            return {
              id: item.id,
              goodId: item.id,
              goodName: item.categoryName,
            };
          });
          this.PDtab = this.list[0].goodId;
          //默认拿到第一个子级
          this.tabwz = this.list[0].goodName;
          this.GetZi(this.PDtab);
        } else {
          Toast.fail(res.resultMessage);
        }
      });
    });
  },
  methods: {
    //父级切换
    XXtab(val) {
      this.PDtab = val.goodId;
      this.tabwz = val.goodName;
      this.GetZi(val.goodId);
    },
    //子级切换
    XXtabZJ(val) {
      this.PDtabYZFW = val.id;
      this.ZJG = val.goodPrice;
      this.ZJname = val.goodName;
    },
    tabZX(val) {
      this.PDtabYZFW = val.id;
      this.serviceDescription = val.serviceDescription;
    },
    GetZi(val) {
      getVehicleFinanceServiceList({
        siteId: this.siteData.id,
        categoryId: val,
      })
        .then((res) => {
          if (res.resultCode == "1") {
            //拿到子级tab
            this.listYZfu = res.data;
            this.PDtabYZFW = res.data[0].id;
            this.serviceDescription = res.data[0].serviceDescription;
            this.mobile = res.data[0].mobile;
            this.serviceStaff = res.data[0].serviceStaff;
            this.ZJG = res.data[0].goodPrice;
            this.ZJname = res.data[0].serviceName;
          } else {
            Toast.fail(res.resultMessage);
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>

<style lang="less" scoped>
@import "../../static/css/index.less";
@import "../../static/css/GYcSS.less";
.cssXX {
  background: rgb(54, 194, 168);
  color: #fff;
  border-radius: 5px;
}

.title {
  font-size: 15px;
  font-weight: 700;
  margin: 5px 0;
  margin-top: 10px;
}

.text {
  font-size: 12px;
  line-height: 20px;
}

.YBlist {
  padding: 0 10px;
  padding-top: 0px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  .ul {
    width: 47%;
    flex-shrink: 0;
    border: 1px solid rgba(225, 229, 243, 1);
    background: rgba(255, 255, 255, 1);
    text-align: center;
    border-radius: 5px;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 50px;

    .li {
    }
  }
}

.FWGS {
  box-sizing: border-box;

  .l {
    font-size: 12px;
    line-height: 20px;
  }
}

.DI {
  position: fixed;
  z-index: 999;
  width: 90%;
  left: 50%;
  bottom: 0px;
  transform: translate(-50%, -10px);
  font-size: 12px;
  text-align: center;
  font-weight: 600;

  .DI_top {
    color: rgb(2, 117, 113);
    margin-bottom: 5px;
  }

  .DI_bottom {
    width: 100%;
    height: 50px;
    line-height: 50px;
    background: rgb(2, 117, 113);
    color: #fff;
    border-radius: 5px;
  }
}

.FWxx {
  .ul {
    .title {
      font-size: 15px;
      font-weight: 700;
      margin: 5px 0;
      margin-top: 10px;
    }

    .text {
      font-size: 12px;
      line-height: 20px;
    }

    // padding: 0 40rpx;
    padding: 10px;
    box-sizing: border-box;

    .li {
      display: flex;
      align-items: center;

      // background: #fff;
      .li_left {
        width: 80px;
        height: 80px;
        margin-right: 10px;

        image {
          width: 80px;
          height: 80px;
        }
      }

      .li_right {
        font-size: 18px;
        line-height: 35px;
      }
    }
  }
}
.NR {
  background: #fff;
  width: 95%;
  padding: 10px;
  box-sizing: border-box;
  margin: 0 auto;
  border-radius: 15px;
  position: relative;
  margin-top: 20px;
  padding-top: 40px;
  padding-bottom: 40px;
  //   height: calc(100vh - 200px);
  overflow-y: auto;

  .RYXX {
    color: rgba(69, 67, 67, 1);
    line-height: 30px;
    letter-spacing: 1px;
    text-indent: 2em;
    font-size: 12px;
  }

  .title {
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    color: rgb(54, 194, 168);
    position: absolute;
    left: 50%;
    top: 25px;
    transform: translate(-50%, -10px);

    .H {
      font-size: 14px;
    }

    .XX {
      font-weight: 700;
      margin: 0 5px;
    }
  }
}
</style>